package com.ruoyi.web.controller.yijing;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yijing.domain.YjGuaCategory;
import com.ruoyi.yijing.service.IYjGuaiCategoryService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 卦和占卜问题的关系Controller
 * 
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/yijing/guai/category")
public class YjGuaiCategoryController extends BaseController
{
    @Autowired
    private IYjGuaiCategoryService yjGuaiCategoryService;

    /**
     * 查询卦和占卜问题的关系列表
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjGuaCategory yjGuaiCategory)
    {
        if (yjGuaiCategory.getGuaId() == null){
            yjGuaiCategory.setGuaId(0);
        }
        startPage();
        List<YjGuaCategory> list = yjGuaiCategoryService.selectYjGuaiCategoryList(yjGuaiCategory);
        return getDataTable(list);
    }

    /**
     * 获取卦和占卜问题的关系详细信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:query')")
    @GetMapping(value = "/{yxId}")
    public AjaxResult getInfo(@PathVariable("yxId") Long yxId)
    {
        return success(yjGuaiCategoryService.selectYjGuaiCategoryByYxId(yxId));
    }

    /**
     * 新增卦和占卜问题的关系
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:add')")
    @Log(title = "卦和占卜问题的关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjGuaCategory yjGuaiCategory)
    {
        return toAjax(yjGuaiCategoryService.insertYjGuaiCategory(yjGuaiCategory));
    }

    /**
     * 修改卦和占卜问题的关系
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:edit')")
    @Log(title = "卦和占卜问题的关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjGuaCategory yjGuaiCategory)
    {
        return toAjax(yjGuaiCategoryService.updateYjGuaiCategory(yjGuaiCategory));
    }

    /**
     * 删除卦和占卜问题的关系
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:remove')")
    @Log(title = "卦和占卜问题的关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yxId}")
    public AjaxResult remove(@PathVariable Long yxId)
    {
        return toAjax(yjGuaiCategoryService.deleteYjGuaiCategoryByYxId(yxId));
    }
}
